import { Injectable, Logger } from "@nestjs/common";
import { Log } from "./log.entity";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";
import { UserSys } from "src/user/userSys.entity";



@Injectable()
export class LogService {
    constructor(
        @InjectRepository(Log)
        public readonly log: Repository<Log>
    ) { }
    async create(
        user: UserSys,
        name: string,
        path: string,
        method: string,
        statusCode: number,
        body: string,
        data: string,
        ip: string
    ) {
        const entity = this.log.create({
            user,
            name,
            path,
            statusCode,
            body,
            data,
            method,
            ip
        })
        await this.log.save(entity);
    }
}